package com.qianli.user.facade.impl.social;

import com.fqgj.common.api.Response;
import com.qianli.user.application.UserSocialApplication;
import com.qianli.user.facade.social.UserSocialServiceFacade;
import com.qianli.user.ro.UserStateCode;
import com.qianli.user.ro.social.UserContactAddressBookRO;
import com.qianli.user.ro.social.UserContactEmergencyRO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * name:社交信息
 * auth:ting.li@qianli-inc.com
 * date:2018/1/3 14:12
 * version: v1.0.0
 **/
@Service("userSocialServiceFacade")
public class UserSocialServiceFacadeImpl implements UserSocialServiceFacade{

    private static final Logger LOGGER = LoggerFactory.getLogger(UserSocialServiceFacade.class);
    @Autowired
    private UserSocialApplication userSocialApplication;


    @Override
    public Response<Boolean> saveUserContactAddressBook(UserContactAddressBookRO userContactAddressBook) {
        if(null == userContactAddressBook){
            LOGGER.info("UserSocialServiceFacade.saveUserContactAddressBook param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userContactAddressBook.getUserCode()){
            LOGGER.info("UserSocialServiceFacade.saveUserContactAddressBook param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数userCode不能为空");
        }
        if(null == userContactAddressBook.getContactUrl()){
            LOGGER.info("UserSocialServiceFacade.saveUserContactAddressBook param contactUrl can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数contactUrl不能为空");
        }
        Response<Boolean> response = userSocialApplication.saveUserContactAddressBook(userContactAddressBook);
        return response;
    }

    @Override
    public Response<Boolean> saveUserContactEmergency(UserContactEmergencyRO userContactEmergency) {
        if(null == userContactEmergency){
            LOGGER.info("UserSocialServiceFacade.saveUserContactEmergency param can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userContactEmergency.getUserCode()){
            LOGGER.info("UserSocialServiceFacade.saveUserContactEmergency param userCode can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        if(null == userContactEmergency.getFamilyType()){
            LOGGER.info("UserSocialServiceFacade.saveUserContactEmergency param familyType can not be null");
            return Response.error(UserStateCode.PARAMETER_LACK,"参数不能为空");
        }
        Response<Boolean> response = userSocialApplication.saveUserContactEmergency(userContactEmergency);
        return response;
    }
}
